<html>
<body id="bodys">

<audio id="ms" src="./img/m1.ogg" autoplay controls>
<!--    <source src="/img/m1.ogg" type="audio/ogg" />-->
<!--    <source src="/img/m1.mp3" type="audio/mpeg" />-->
    Your browser does not support the audio element.
</audio>

</body>
</html>

<script>


    var music = document.getElementById("ms");
    var bodys = document.getElementById("bodys");
    var e = document.createEvent("MouseEvents");

    e.initEvent("click", true, true);

    document.getElementById("ms").dispatchEvent(e);
    console.dir(music);


    bodys.onclick = plays;
    function plays(e){
        music.play();
        console.log(e)
    }
    // setInterval(function(){
    //     // music.muted = false;
    //     music.play()
    // // var music = document.getElementById("ms")
    // // setTimeout(function () {
    // //     music.click()
    // },1000)


// setTimeout(function () {
//
//     var e = document.createEvent("MouseEvents");
//     e.initEvent("click", true, true);
//     document.getElementById("ms").dispatchEvent(e)
//     console.log('111')
// },1000)
//     function toggleSound() {
//         var music = document.getElementById("vd");//获取ID  
//         console.log(music);
//         console.log(music.paused);
//         if (music.paused) { //判读是否播放  
//             music.paused=false;
//             music.play(); //没有就播放 
//         }
//
//     }
//
//     setInterval("toggleSound()",1);


</script>
